<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>管理页面</title>
<link href="{webroot}theme/admin/css/iframe.css" rel="stylesheet" type="text/css" />
<link href="{webroot}theme/admin/css/iconfont.css" rel="stylesheet" type="text/css" />
<script src="{webroot}lib/js/jquery.js"></script>
<script src="{webroot}lib/js/jquery-migrate-1.1.0.min.js"></script>
<script src="{webroot}lib/js/base.js"></script>
<script src="{webroot}lib/tips/jquery.tips.js"></script>
<script src="{webroot}lib/js/jquery.vtip.js"></script>
<script src="{webroot}lib/validator/jquery.validator.js"></script>
<script src="{webroot}lib/validator/zh_CN.js"></script>
<script src="{webroot}theme/admin/js/admin.js"></script>
<script src="{webroot}lib/dialog/artdialog.js"></script>
<!--[if lt IE 9]>
<script src="{webroot}lib/js/html5.js"></script>
<![endif]-->
<script>
$(function(){
	$(".del").click(function(){
		var id;
		id=$(this).attr("rel");
		var that=this;
			top.dialog({
				content:'\u786e\u5b9a\u8981\u5220\u9664\uff1f\u4e0d\u53ef\u6062\u590d\uff01',
				ok:function(){
					var url,data;
					url='?act=del&id='+id;
					$.ajax({
					type:"get",
					cache:false,
					url:url,
					success:function(_)
					{
						if(_.substring(0,1)==0)
						{
							$.fn.tips({type:"error",content:_.substring(1)});
						}
						else
						{
							$.fn.tips({type:"ok",content:"\u5220\u9664\u6210\u529f"});
							$(that).parent().parent().fadeOut('slow');
						}
					}
					});
									
					},
				cancel:true 
			}).showModal();
		
		})
})
</script>
</head>
<body>

<div class="layout-center">
	<div class="right_subject">当前位置：栏目 > <a href="sd_form.asp">表单管理</a> > <a href="?act=field&formid={formid}">字段管理</a></div>
    <div class="right_body">
        <div class="nav_menu">
            <ul>
                <li><a href="?act=add&formid={formid}"><span class="iconfont">&#xe618;</span>添加字段</a></li>
            </ul>
        </div>
        
        <div class="table_title">
        字段列表
        </div>
        <form class="formname" method="post">
        <table id="tablelist">
            <thead>
                <tr>
                    <th width="40">ID</th>
                    <th width="80">排序</th>
                    <th>字段名称</th>
                    <th width="150">字段别名</th>
                    <th width="100">字段类型</th>
                    <th width="80">数据类型</th>
                    <th width="80">是否必填</th>
                    <th width="80">列表显示</th>
                    <th width="60">状态</th>
                    <th width="100">管理</th>
                </tr>
            </thead>
            <tbody>
            {dim islist:islist=1}
            {sdcms:rs top="0" table="sd_form_field" where="formid=[formid]" order="ordnum,id"}
            {rs:eof}
            <%islist=0%>
            <tr>
                <td colspan="10">没有资料</td>
            </tr>
            {/rs:eof}
            <tr>
                <td>{$rs[id]}</td>
                <td><input type="hidden" name="id" value="{$rs[id]}" ><input type="text" name="ordnum" id="{$rs[id]}" value="{$rs[ordnum]}" size="4" maxlength="4" class="ordnum" data-rule="排序:required;digit"></td>
                <td class="txt_left">{$rs[fname]}</td>
                <td>{$rs[falias]}</td>
                <td>{get_type($rs[fclass])}</td>
                <td>{get_data($rs[fdatatype])}</td>
                <td>{sdcms.iif($rs[fismust]=0,"<span>否</span>","是")}</td>
                <td>{if $rs[fdatatype]=5}<span>-</span>{else}{sdcms.iif($rs[isshow]=0,"<span>否</span>","是")}{/if}</td>
                <td>{sdcms.iif($rs[islock]=0,"<span>锁定</span>","正常")}</td>
                <td><a href="?act=edit&id={$rs[id]}&formid={formid}">编辑</a>　<a href="javascript:;" class="del" rel="{$rs[id]}">删除</a></td>
            </tr>
            {/sdcms:rs}            
        </table>
        {if islist=1}
        <div class="table_bottom">
        <input type="submit" value="保存排序" class="ordbnt">
        </div>
        {/if}
        </form>
    </div>
</div>
<script>
$(".formname").validator(
	{
		stopOnError:true,
        theme:'yellow_top',
		ignore:':hidden',
		beforeSubmit:function(){$("input[type='submit']").attr("disabled",true);},
		valid:function(form)
		{
			$.fn.tips({type:'loading',content:'数据提交中'});
			$.ajax(
			{
				url:"?act=order&formid={formid}",
				type:"post",
				data:$(form).serialize(),
				success:function(data){
					data=jQuery.parseJSON(data);
					var type="warn";
					if(data.status=="y"){type="ok";}
					$.fn.tips({type:type,content:data.info});
					if(data.status=="y"){setTimeout("location.href='?formid={formid}'",1000);}
					else
					{$("input[type='submit']").attr("disabled",false);}
					
				}
			});
		},
		invalid:function(){$("input[type='submit']").attr("disabled",false);}
	}
);
</script>
</body>
</html>